<?=view('header.html')?>
<section class="section">

	<form id="J_install_form" action="<?=url('install/index', ['code'=>$code,'step' => $step])?>" method="post" onsubmit="return installSubmit()">

		<div class="server">
			<table class="layui-table table-hover">
				<tr>
					<td class="td1" width="100">数据库信息</td>
					<td class="td1" colspan="2">&nbsp;修改文件 APPPATH.Config/Database.php</td>
				</tr>
				<tr>
					<td class="td1" width="100">创始人信息</td>
					<td class="td1" width="200">&nbsp;</td>
					<td class="td1">&nbsp;</td>
				</tr>
				<tr>
					<td class="tar">管理员：</td>
					<td><input type="text" class="layui-input" name="data[admin]" value="admin"></td>
					<td>
						<div id="J_install_tip_admin"></div>
					</td>
				</tr>
				<tr>
					<td class="tar">密码：</td>
					<td><input type="text" class="layui-input" name="data[password]" id="J_manager_pwd" value="admin"></td>
					<td>
						<div id="J_install_tip_password"><span class="gray">最少6位，可以使用 数字、字母、符号(_ - @ *) 的组合</span></div>
					</td>
				</tr>
				<tr>
					<td class="tar">后台登录码:</td>
					<td><input type="text" class="layui-input" name="data[hash]" readonly required placeholder="重要:请牢记,否则无法登录后台" value="<?=ams_randstr(6,0)?>"></td>
					<td>
						<div id="J_install_tip_admin"><span class="gray">后台登录地址:网址/admin?hash=后台登录码</span></div>
					</td>
				</tr>
				<tr>
					<td class="tar">Email：</td>
					<td><input type="text" class="layui-input" name="data[email]" value="" /></td>
					<td>
						<div id="J_install_tip_email"><span class="gray"></span></div>
					</td>
				</tr>
			</table>

		</div>
		<div class="bottom tac">
			<a href="<?=url('install/index', ['code'=>$code,'step' => $step-1])?>" class="layui-btn layui-btn-warm">上一步</a>
			<button type="button" class="layui-btn layui-btn-blue J_install_btn">安装数据库</button>
		</div>
	</form>
</section>

<script type="text/javascript">

	layui.use(['form', 'element', 'layer', 'table', 'laydate', 'upload', 'jquery'], function () {
		var form = layui.form,
			element = layui.element,
			layer = layui.layer,
			$ = layui.jquery;


		$('.J_install_btn').on('click', function () {
			var url = $("#J_install_form").attr('action');
			var install_form = $("#J_install_form");
			var _data = $("#J_install_form").serialize();

			$.post(url, _data, function (res) {
				if (res.code == 0) {
					window.location.href = res.data;
				} else {
					layer.msg('<span class="tips_error">' + res.msg + '</span>', { icon: 5 });
				}
			}, 'json');
			return false;
		})


	});

</script>
<?=view('footer.html')?>